// logs.js
import {goodsInfo} from '../../utils/api'

Page({
  data: {
    id: '',
    info: {},
    storeId: '',
  },
  onLoad(options) {
    this.setData({
      storeId: options.storeId,
      id: options.id
    })
    this.getData()
  },
  getData () {
    goodsInfo(this.data.id).then(res => {
      if (res.subtitle && res.subtitle.includes(',')) {
        res.subtitle = res.subtitle.split(',')
      }
      this.setData({
        info: res
      })
    })
  },
  toBuy () {
    wx.navigateTo({
      url: '/pages/order/order?storeId=' + this.data.storeId + '&id=' + this.data.info.id,
    })
  },
})
